
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第八章 指针类型(1) · C语言程序设计精髓程</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="马小安">
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-disqus/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-prism/prism-base16-ateliersulphurpool.light.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-katex/katex.min.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-terminal/plugin.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="chapter8_2.html" />
    
    
    <link rel="prev" href="chapter7.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                        <b>1.1.</b>
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="chapter1.html">
            
                <a href="chapter1.html">
            
                    
                        <b>1.2.</b>
                    
                    第一章 基础知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="chapter2.html">
            
                <a href="chapter2.html">
            
                    
                        <b>1.3.</b>
                    
                    第二章 数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="chapter3.html">
            
                <a href="chapter3.html">
            
                    
                        <b>1.4.</b>
                    
                    第三章 顺序结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="chapter4.html">
            
                <a href="chapter4.html">
            
                    
                        <b>1.5.</b>
                    
                    第四章 选择结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="chapter5.html">
            
                <a href="chapter5.html">
            
                    
                        <b>1.6.</b>
                    
                    第五章 循环结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="chapter6.html">
            
                <a href="chapter6.html">
            
                    
                        <b>1.7.</b>
                    
                    第六章 数组概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="chapter7.html">
            
                <a href="chapter7.html">
            
                    
                        <b>1.8.</b>
                    
                    第七章 函数与预编译
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.9" data-path="chapter8_1.html">
            
                <a href="chapter8_1.html">
            
                    
                        <b>1.9.</b>
                    
                    第八章 指针类型(1)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="chapter8_2.html">
            
                <a href="chapter8_2.html">
            
                    
                        <b>1.10.</b>
                    
                    第八章 指针类型(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="chapter9_1.html">
            
                <a href="chapter9_1.html">
            
                    
                        <b>1.11.</b>
                    
                    第九章 结构体类型(1)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="chapter9_2.html">
            
                <a href="chapter9_2.html">
            
                    
                        <b>1.12.</b>
                    
                    第九章 结构体类型(2)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="chapter9_3.html">
            
                <a href="chapter9_3.html">
            
                    
                        <b>1.13.</b>
                    
                    第九章 结构体类型(3)
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="chapter10.html">
            
                <a href="chapter10.html">
            
                    
                        <b>1.14.</b>
                    
                    第十章 位运算
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="chapter11.html">
            
                <a href="chapter11.html">
            
                    
                        <b>1.15.</b>
                    
                    第十一章 排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="Glossary.html">
            
                <a href="Glossary.html">
            
                    
                        <b>1.16.</b>
                    
                    其他资源
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >第八章 指针类型(1)</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x4E00;&#x3001;-&#x6307;&#x9488;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;">&#x4E00;&#x3001; &#x6307;&#x9488;&#x53D8;&#x91CF;&#x5B9A;&#x4E49;</h2>
<p>C&#x8BED;&#x8A00;&#x6709;&#x4E24;&#x79CD;&#x5E38;&#x91CF;&#xFF1A;</p>
<ul>
<li>&#x503C;&#x5E38;&#x91CF;</li>
<li>&#x7B26;&#x53F7;&#x5E38;&#x91CF;</li>
</ul>
<p>C&#x8BED;&#x8A00;&#x6709;&#x4E24;&#x79CD;&#x53D8;&#x91CF;&#xFF1A;</p>
<ul>
<li>&#x5185;&#x5BB9;&#x53D8;&#x91CF;&#x2014;&#x2014;&#x666E;&#x901A;&#x53D8;&#x91CF;</li>
<li>&#x5730;&#x5740;&#x53D8;&#x91CF;&#x2014;&#x2014;&#x6307;&#x9488;&#x53D8;&#x91CF;</li>
</ul>
<h1 id="&#x6307;&#x9488;&#x53D8;&#x91CF;&#x7684;&#x5B9A;&#x4E49;&#xFF1A;&#x7C7B;&#x578B;&#x540D;-----&#x6307;&#x9488;&#x53D8;&#x91CF;&#x540D;">&#x6307;&#x9488;&#x53D8;&#x91CF;&#x7684;&#x5B9A;&#x4E49;&#xFF1A;&#x7C7B;&#x578B;&#x540D;    * &#x6307;&#x9488;&#x53D8;&#x91CF;&#x540D;</h1>
<ul>
<li>int a,b,<em>p1,</em>p2;</li>
<li>float a,b,<em>p3,</em>p4;</li>
<li>char s,<em>p5,</em>p6;</li>
</ul>
<h3 id="&#x6CE8;&#x610F;&#x4E8B;&#x9879;"><strong>==&#x6CE8;&#x610F;&#x4E8B;&#x9879;==</strong></h3>
<ul>
<li>&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#xFF08;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x3001;&#x666E;&#x901A;&#x53D8;&#x91CF;&#xFF09;&#x90FD;&#x5FC5;&#x987B;&#x5728;&#x524D;&#x9762;&#x6DFB;&#x52A0;&#x7C7B;&#x578B;&#x540D;</li>
<li>&#x5B9A;&#x4E49;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x65F6;&#xFF0C;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x524D;&#x9762;&#x7684;&#x201C;*&#x201D;&#x8868;&#x793A;&#x5B9A;&#x4E49;&#x7684;&#x662F;&#x4E00;&#x4E2A;&#x6307;&#x9488;&#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x661F;&#x53F7;&#x4E0D;&#x662F;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x53EA;&#x662F;&#x4E00;&#x4E2A;&#x6807;&#x5FD7;&#x3002;</li>
<li>&#x6307;&#x9488;&#x53D8;&#x91CF;&#x4E13;&#x95E8;&#x7528;&#x6765;&#x5B58;&#x50A8;&#x5730;&#x5740;&#xFF0C;&#x7981;&#x6B62;&#x5C06;&#x4E00;&#x4E2A;&#x6574;&#x578B;&#x76F4;&#x63A5;&#x8D4B;&#x503C;&#x7ED9;&#x4E00;&#x4E2A;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x3002;</li>
<li>&#x5185;&#x5BB9;&#x53D8;&#x91CF;&#x5B58;&#x5185;&#x5BB9;&#xFF0C;&#x5730;&#x5740;&#x53D8;&#x91CF;&#x5B58;&#x5730;&#x5740;<h1 id="&#x6307;&#x9488;&#x53D8;&#x91CF;&#x7684;&#x5F15;&#x7528;">&#x6307;&#x9488;&#x53D8;&#x91CF;&#x7684;&#x5F15;&#x7528;</h1>
</li>
<li>&#x201C;*&#x201D;&#x4E3A;&#x6307;&#x9488;&#x8FD0;&#x7B97;&#x7B26;&#xFF0C;&#x53EF;&#x4EE5;&#x53D6;&#x51FA;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x6307;&#x5411;&#x7684;&#x666E;&#x901A;&#x53D8;&#x91CF;&#x7684;&#x503C;&#xFF08;&#x95F4;&#x63A5;&#x5F15;&#x7528;&#x666E;&#x901A;&#x53D8;&#x91CF;&#xFF09;</li>
<li>&#x201C;&amp;&#x201D;&#x4E3A;&#x5730;&#x5740;&#x8FD0;&#x7B97;&#x7B26;&#xFF0C;&#x901A;&#x8FC7;&amp;&#x53EF;&#x4EE5;&#x53D6;&#x51FA;&#x666E;&#x901A;&#x53D8;&#x91CF;&#x4E2D;&#x7684;&#x5730;&#x5740;&#xFF08;&#x5355;&#x76EE;&#xFF0C;&#x4E8C;&#x7EA7;&#xFF0C;&#x4ECE;&#x53F3;&#x5411;&#x5DE6;&#x8FD0;&#x7B97;&#xFF09;<h2 id="&#x6CE8;&#x610F;&#x4E8B;&#x9879;"><strong>==&#x6CE8;&#x610F;&#x4E8B;&#x9879;==</strong></h2>
</li>
<li>(1)&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8D4B;&#x503C;&#x4F7F;&#x4E00;&#x4E2A;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x201C;&#x6307;&#x5411;&#x201D;&#x67D0;&#x4E00;&#x666E;&#x901A;&#x53D8;&#x91CF;(&#x6307;&#x9488;&#x53D8;&#x91CF;=&amp;&#x666E;&#x901A;&#x53D8;&#x91CF;),&#x6BD4;&#x5982;&#xFF1A;int a=10;int *p;p=&amp;a;</li>
<li>(2)&#x5148;&#x8BA9;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x6307;&#x5411;&#x4E00;&#x4E2A;&#x786E;&#x5B9A;&#x7684;&#x5B58;&#x50A8;&#x5355;&#x5143;&#x4E4B;&#x540E;&#xFF0C;&#x518D;&#x901A;&#x8FC7;&#x8BE5;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x5F15;&#x7528;&#x5B83;&#x6240;&#x6307;&#x5411;&#x7684;&#x5B58;&#x50A8;&#x5355;(&#x5B9A;&#x4E49;&#x4E14;&#x521D;&#x59CB;&#x5316;&#x4E4B;&#x540E;&#x65B9;&#x53EF;&#x7528;&#xFF0C;&#x4E0D;&#x53EF;&#x4EE5;&#x968F;&#x4FBF;&#x6307;&#x5411;&#x666E;&#x901A;&#x53D8;&#x91CF;&#x6216;&#x5E38;&#x91CF;)</li>
<li>(3)&#x53D8;&#x91CF;&#x540D;(&#x666E;&#x901A;&#x53D8;&#x91CF;&#x548C;&#x6307;&#x9488;&#x53D8;&#x91CF;)&#x90FD;&#x8868;&#x793A;&#x5B58;&#x50A8;&#x5355;&#x5143;&#x7684;&#x503C;&#x3002;int <em>p1,</em>p2;p1=p2;<em>p1(&#x5199;)=</em>p2(&#x8BFB;);&#x540E;&#x9762;&#x8BED;&#x53E5;&#x5747;&#x5408;&#x6CD5;&#x3002;</li>
<li>==<strong>&#x5185;&#x5BB9;&#x53D8;&#x91CF;&#x753B;&#x623F;&#x5B50;&#xFF0C;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x753B;&#x6307;&#x5411;</strong>==</li>
<li>(4)&#x82E5;&#x6307;&#x9488;&#x53D8;&#x91CF;p&#x6307;&#x5411;&#x666E;&#x901A;&#x53D8;&#x91CF;a&#xFF0C;&#x5373;&#x5C06;&#x53D8;&#x91CF;a&#x7684;&#x5730;&#x5740;&#x8D4B;&#x7ED9;&#x4E86;&#x6307;&#x9488;&#x53D8;&#x91CF;p&#x3002;</li>
<li>&#x5982;&#xFF1A;int a =10,*p=&amp;a;&#x5219;&#x6709;&#x5982;&#x4E0B;&#x7ED3;&#x679C;&#xFF08;&#x505A;&#x9898;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x7B49;&#x4EF7;&#x66FF;&#x6362;&#xFF09;&#xFF1A;<ul>
<li>*p&lt;=&gt;a</li>
<li>p&lt;=&gt;&amp;a</li>
<li>&amp;*p&lt;=&gt;&amp;a&lt;=&gt;p</li>
<li><em>&amp;a &lt;=&gt;</em>p &lt;=&gt;a</li>
<li>(*p)++ a++</li>
<li>(*p)-- a--</li>
<li>--(<em>p) --a --</em>p(&#x5355;&#x76EE;&#xFF0C;&#x4E8C;&#x7EA7;&#xFF0C;&#x7ED3;&#x5408;&#x65B9;&#x5411;&#x4ECE;&#x53F3;&#x5411;&#x5DE6;)</li>
<li>++(<em>p) ++a ++</em>p</li>
<li>==&#x6CE8;&#xFF1A;&#x4E0A;&#x8FF0;&lt;=&gt;&#x4E3A;&#x7B49;&#x4EF7;&#x4E8E;&#xFF0C;&#x4E3A;&#x7B49;&#x4EF7;&#x8868;==</li>
</ul>
</li>
<li>(5)&#x6240;&#x6709;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x5728;&#x5185;&#x5B58;&#x4E2D;&#x5206;&#x914D;&#x7684;&#x5B57;&#x8282;&#x6570;(&#x5747;&#x4E3A;2&#x4F4D;)&#x90FD;&#x662F;&#x76F8;&#x540C;&#x7684;&#xFF0C;sizeof();int <em>p1;double </em>p2;float *p3;&#x4E09;&#x4E2A;&#x7684;sizeof&#x76F8;&#x540C;&#xFF0C;&#x8BE5;&#x7C7B;&#x578B;&#x6307;&#x7684;&#x662F;&#x666E;&#x901A;&#x53D8;&#x91CF;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x540C;&#x7C7B;&#x578B;&#x4E92;&#x6307;&#x3002;</li>
</ul>
<h1 id="&#x7684;&#x4E09;&#x89D2;&#x8272;">&#x201C;*&#x201D;&#x7684;&#x4E09;&#x89D2;&#x8272;</h1>
<ul>
<li>&#x4E58;&#x6CD5;&#x8FD0;&#x7B97;&#x7B26;(&#x53CC;&#x76EE;)</li>
<li>&#x6307;&#x9488;&#x8FD0;&#x7B97;&#x7B26;(2&#x7EA7;&#xFF0C;&#x5355;&#x76EE;&#xFF0C;&#x4ECE;&#x53F3;&#x5411;&#x5DE6;)</li>
<li>&#x6307;&#x9488;&#x5B9A;&#x4E49;&#x7684;&#x6807;&#x5FD7;&#xFF0C;&#x8BE5;*&#x4E0D;&#x662F;&#x53D8;&#x91CF;&#x7684;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x662F;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x7684;&#x6807;&#x5FD7;</li>
<li></li>
</ul>
<h1 id="&#x53E3;&#x8BC0;&#xFF1A;">&#x53E3;&#x8BC0;&#xFF1A;</h1>
<h2 id="1-&#x8BA1;&#x7B97;&#x8868;&#x8FBE;&#x5F0F;">1. &#x8BA1;&#x7B97;&#x8868;&#x8FBE;&#x5F0F;</h2>
<h2 id="2-&#x5206;&#x6790;&#x7A0B;&#x5E8F;&#x6709;&#x591A;&#x5C11;&#x6761;&#x8BED;&#x53E5;&#xFF0C;&#x7ED3;&#x6784;&#x7684;">2. &#x5206;&#x6790;&#x7A0B;&#x5E8F;&#x6709;&#x591A;&#x5C11;&#x6761;&#x8BED;&#x53E5;&#xFF0C;&#x7ED3;&#x6784;&#x7684;</h2>
<h2 id="3-&#x590D;&#x5408;&#x6846;&#x67B6;&#x6267;&#x884C;&#x8FC7;&#x7A0B;">3. &#x590D;&#x5408;&#x6846;&#x67B6;&#x6267;&#x884C;&#x8FC7;&#x7A0B;</h2>
<h2 id="4-&#x6307;&#x9488;&#xFF08;1&#x5730;&#x5740;&#x53D8;&#x91CF;&#x5F97;&#x5730;&#x5740;&#xFF0C;-&#x6307;&#x5411;&#x8C01;&#x5F97;&#x5230;&#x8C01;&#x7684;&#x5730;&#x5740;&#xFF1B;-2&#x6709;&#x662F;&#x5185;&#x5BB9;&#x503C;&#xFF0C;&#x4E0D;&#x662F;&#x8BFB;&#x5C31;&#x662F;&#x5199;&#xFF0C;&#x5728;&#x8D4B;&#x503C;&#x53F7;&#x5DE6;&#x8FB9;&#x662F;&#x5199;&#xFF0C;&#x5728;&#x8D4B;&#x503C;&#x53F7;&#x53F3;&#x8FB9;&#x662F;&#x8BFB;3&#x65E0;&#x6539;&#x53D8;&#x91CF;&#x6307;&#x5411;&#x7684;&#x5730;&#x5740;4&#x6307;&#x9488;&#x53D8;&#x91CF;&#x5FC5;&#x987B;&#x5B9A;&#x4E49;&#x4E14;&#x521D;&#x59CB;&#x5316;&#x4E4B;&#x540E;&#x65B9;&#x53EF;&#x7528;&#xFF09;">4. &#x6307;&#x9488;&#xFF08;1.&#x5730;&#x5740;&#x53D8;&#x91CF;&#x5F97;&#x5730;&#x5740;&#xFF0C; &#x6307;&#x5411;&#x8C01;&#x5F97;&#x5230;&#x8C01;&#x7684;&#x5730;&#x5740;&#xFF1B; 2.&#x6709;<em>&#x662F;&#x5185;&#x5BB9;&#x503C;&#xFF0C;&#x4E0D;&#x662F;&#x8BFB;&#x5C31;&#x662F;&#x5199;&#xFF0C;&#x5728;&#x8D4B;&#x503C;&#x53F7;&#x5DE6;&#x8FB9;&#x662F;&#x5199;&#xFF0C;&#x5728;&#x8D4B;&#x503C;&#x53F7;&#x53F3;&#x8FB9;&#x662F;&#x8BFB;3.&#x65E0;\</em>&#x6539;&#x53D8;&#x91CF;&#x6307;&#x5411;&#x7684;&#x5730;&#x5740;4.(&#x6307;&#x9488;&#x53D8;&#x91CF;&#x5FC5;&#x987B;&#x5B9A;&#x4E49;&#x4E14;&#x521D;&#x59CB;&#x5316;&#x4E4B;&#x540E;&#x65B9;&#x53EF;&#x7528;&#xFF09;</h2>
<h1 id="&#x6307;&#x9488;&#x4F8B;&#x9898;&#x5206;&#x6790;">&#x6307;&#x9488;&#x4F8B;&#x9898;&#x5206;&#x6790;</h1>
<h3 id="&#x4F8B;&#x4E00;">&#x4F8B;&#x4E00;</h3>
<pre class="language-"><code class="lang-C">void fun(int *x, int *y);//&#x539F;&#x578B;&#x58F0;&#x660E;&#xFF0C;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x4E3A;&#x6307;&#x9488;&#x53D8;&#x91CF;
int main(void) 
{
    int x = 1, y = 2;
    fun(&amp;y, &amp;x);
    printf(&quot;%d%d&quot;, x, y);//&#x6253;&#x5370;&#x666E;&#x901A;&#x53D8;&#x91CF;
    getchar();
    return 0;
}

void fun(int *x, int *y) //&#x5F62;&#x53C2;&#x4E3A;&#x6307;&#x9488;&#x53D8;&#x91CF;
{
    printf(&quot;%d%d&quot;, *x, *y);    // &#x6253;&#x5370;&#x5F62;&#x53C2;&#x6307;&#x9488;&#x6240;&#x6307;&#x5411;&#x7684;&#x666E;&#x901A;&#x53D8;&#x91CF;&#x7684;&#x503C;
    *x = 3;    //&#x66F4;&#x6539;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x6240;&#x6307;&#x5411;&#x7684;&#x666E;&#x901A;&#x53D8;&#x91CF;&#x7684;&#x5185;&#x5BB9;&#x503C;&#xFF0C;&#x4E0B;&#x540C;
    *y = 4;
}
</code></pre>
<h4 id="&#x4F8B;&#x4E8C;&#xFF08;&#x753B;&#x56FE;&#xFF0C;&#x53E3;&#x8BC0;&#xFF09;">&#x4F8B;&#x4E8C;&#xFF08;&#x753B;&#x56FE;&#xFF0C;&#x53E3;&#x8BC0;&#xFF09;</h4>
<pre class="language-"><code class="lang-C">void swap(int *p1, int *p2);

int main(void) {
    int a, b;
    int *p1 = &amp;a, *p2 = <span class="token entity" title="&amp;b;">&amp;b;</span>
    scanf(&quot;%d%d&quot;, &amp;a, &amp;b);
    swap(p1,p2);
    printf(&quot;%d,%d&quot;,*p1,*p2);
    getchar();
    getchar();
    return 0;
}

void swap(int *p1, int *p2) 
{
    int temp;
    temp = *p1;
    *p1 = *p2;
    *p2 = temp;
}
</code></pre>
<h3 id="&#x4F8B;&#x4E09;&#xFF08;&#x753B;&#x56FE;&#xFF0C;&#x5E94;&#x7528;&#x6307;&#x9488;&#x53E3;&#x8BC0;&#xFF0C;&#x6539;&#x53D8;&#x6307;&#x9488;&#x6307;&#x5411;&#xFF09;">&#x4F8B;&#x4E09;&#xFF08;&#x753B;&#x56FE;&#xFF0C;&#x5E94;&#x7528;&#x6307;&#x9488;&#x53E3;&#x8BC0;&#xFF0C;&#x6539;&#x53D8;&#x6307;&#x9488;&#x6307;&#x5411;&#xFF09;</h3>
<pre class="language-"><code class="lang-C">void swap2(int *p1, int *p2);

int main(void) {
    int a, b;
    int *p1 = &amp;a, *p2 = <span class="token entity" title="&amp;b;">&amp;b;</span>
    scanf(&quot;%d%d&quot;, &amp;a, &amp;b);
    swap2(p1,p2);
    printf(&quot;%d,%d&quot;,*p1,*p2);
    getchar();
    getchar();
    return 0;
}

void swap2(int *p1, int *p2) //&#x53EA;&#x4F1A;&#x4EA4;&#x6362;&#x5C40;&#x90E8;&#x6307;&#x9488;&#x53D8;&#x91CF;&#xFF08;&#x5F62;&#x53C2;&#xFF09;&#x6240;&#x6307;&#x5411;&#x7684;&#x5730;&#x5740;
{
    int *temp;
    temp = p1;
    p1 = p2;
    p2 = temp;
    printf(&quot;%d,%d\n&quot;, *p1, *p2); //&#x5916;&#x90E8;&#x6307;&#x9488;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x6CA1;&#x6709;&#x53D8;&#x5316;
}
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="chapter7.html" class="navigation navigation-prev " aria-label="Previous page: 第七章 函数与预编译">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="chapter8_2.html" class="navigation navigation-next " aria-label="Next page: 第八章 指针类型(2)">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第八章 指针类型(1)","level":"1.9","depth":1,"next":{"title":"第八章 指针类型(2)","level":"1.10","depth":1,"path":"chapter8_2.md","ref":"chapter8_2.md","articles":[]},"previous":{"title":"第七章 函数与预编译","level":"1.8","depth":1,"path":"chapter7.md","ref":"chapter7.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","-highlight","-livereload","search-plus@^0.0.11","disqus@^0.1.0","prism@^2.1.0","prism-themes@^0.0.2","emphasize@^1.1.0","katex@^1.1.3","splitter@^0.0.8","terminal@^0.3.2"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{"css":["prism-themes/themes/prism-base16-ateliersulphurpool.light.css"]},"disqus":{"useIdentifier":false,"shortName":"gitbookuse"},"emphasize":{},"splitter":{},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":2},"prism-themes":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"terminal":{"copyButtons":true,"fade":false,"style":"flat"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"search-plus":{}},"theme":"default","author":"马小安","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"C语言程序设计精髓程","language":"zh-hans","gitbook":"*","description":"苏小红(哈工大)"},"file":{"path":"chapter8_1.md","mtime":"2018-01-31T01:34:29.675Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-01-31T04:39:34.249Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.16.1/URI.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-disqus/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-terminal/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

